package com.itheima.exer.exercise.ex0927;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class CollectionTest2 {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>();
        c.add("张三");
        c.add("张三");
        c.add("李四");
        c.add("张三");
        c.add("张三");
        c.add("王五");
        c.add("赵六");
        System.out.println("集合的长度为:"+c.size());
        System.out.println("集合的内容为:"+c);
        c.remove("张三");
        System.out.println("删除了集合中一个张三"+c);
        c.removeIf(s -> {return "张三".equals(s);});
        System.out.println("删除了集合中所有的张三:"+c);
        boolean contains = c.contains("田七");
        System.out.println("集合中有田七吗?"+contains);
        c.clear();
        boolean empty = c.isEmpty();
        System.out.println("集合为空吗?"+empty);
    }
}
